<!DOCTYPE html>
<html lang="zh-CN" ng-app='he'>
	<head>
		<meta charset='utf-8' />
	
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>请假记录查询</title>
		<style>
			body{
				text-transform: capitalize;
			}
		</style>
		<script type="text/javascript">
			is_local='{{local}}';
			function loadcss(cssfile) {
		        document.write('\<link rel="stylesheet" href="' + cssfile +'" type="text/css"/\>');
		    }
			function loadjs(script_filename) {
		        document.write('\<script language="javascript" type="text/javascript" src="' + script_filename + '"\>\</script\>');
		    }
		    if(!is_local){
			    static_url='/static';
		    }else{
			    static_url='../../../../static';
		    }
		    // 加载所有微信页面需要的js和css
		    loadjs(static_url+'/js/weixin_page.js')
		</script>

		
		<script type="text/javascript">
			var app = angular.module('he',['ngSanitize']);
			app.config(function($interpolateProvider) {
				  $interpolateProvider.startSymbol('[[');
				  $interpolateProvider.endSymbol(']]');
				});
			app.controller('content',function ($scope,$http,$location) {
				// 设置body里面的变量
				if(is_local){
					$scope.this_month={
						personal:100/(8*60),
						sick:100/(8*60),
						annual:100/(8*60),
						other:100/(8*60),
						swap_off:100/60
					};
					$scope.leaves=[
						{id:'1',status:'approved',date:'2016-01-05',category:'annual',span:'2',detail_url:'leave_detail.html?id=fuck'},
						{id:'2',status:'rejected',date:'2016-01-05',category:'annual',span:'2',detail_url:'#'},
						{id:'3',status:'pending',date:'2016-01-05',category:'annual',span:'2',detail_url:'#'},
						{id:'4',status:'revoked',date:'2016-01-05',category:'annual',span:'2',detail_url:'#'},
						{id:'5',status:'checking',date:'2016-01-05',category:'annual',span:'2',detail_url:'#'}]
				}else{
					// 从服务器初始化
					var post_url='/attendance/ajax/';
					
					function init_from_server() {
						var post_data = {
								this_month_leave_report:{},
								leave_record_90:{}
							};  
						$http.post(post_url,post_data)
						.success(function(data, status, headers, config) { 
							$scope.this_month=data.this_month_leave_report;
							$scope.leaves = data.leave_record_90.leaves
						}).error(function(data, status, headers, config) {  
						    //处理错误 
						    $scope.std='有错误,返回码为:'+status;
						});
					}
					init_from_server();
					$scope.leaves=[]
				}
				//--------------------------------------
				$scope.goto=function (url) {
					location=url;
				}
			})
		</script>
	</head>
	<body ng-controller='content'>
		<!-----------------弹出框------------------------>
		<div ng-include src='info_panel.html'></div>
		
		<!-----------------在这里填写内容------------------------>
	<div class="container">
    <div class="row">
        <div class="col-xs-12 clear">
            <ul class="stat" style="padding-bottom: 1em">
                <li class="liTop">For this month</li>
                <li class="lis" style="padding-top: 0">
                    <span class="col-xs-6">Personal Leave</span>
                    <span class="col-xs-6 span2"><span ng-bind='this_month.personal'></span> days</span>
                </li>
                <li class="lis">
                    <span class="col-xs-6">Sick Leave</span>
                    <span class="col-xs-6 span2"><span ng-bind='this_month.sick'></span> days</span>
                </li>
                <li class="lis">
                    <span class="col-xs-6">Annual Leave</span>
                    <span class="col-xs-6 span2"><span ng-bind='this_month.annual'></span> days</span>
                </li>
                <li class="lis">
                    <span class="col-xs-6">Other holidays</span>
                    <span class="col-xs-6 span2"><span ng-bind='this_month.other'></span> days</span>
                </li>
                <li class="lis">
                    <span class="col-xs-6">swap Off</span>
                    <span class="col-xs-6 span2"><span ng-bind='this_month.swap_off'></span> hours</span>
                </li>
            </ul>
        </div>
        <ul class="clear">
	        <li class="li-group col-xs-12" ng-show='leaves.length==0'>
		        最近90天，没有请假记录
	        </li>
            <li class="li-group col-xs-12" ng-click='goto(leave.detail_url)' ng-repeat='leave in leaves | orderBy:"-id"'>
	            <!--<a ng-href="[[leave.detail_url]]">-->
		             <span class="liLeft">
		                <span ng-bind='leave.date'></span> ,
		                <span ng-bind='leave.category'></span> ,
	                	<span ng-hide='leave.category=="swap_off"'><span ng-bind='leave.span' ></span> days</span> 
	                	<span ng-show='leave.category=="swap_off"'><span ng-bind='leave.span' ></span> hours</span> 
                	</span>
	                <span class="liRight span2">
		                <!--  -->
	                    <a  ng-class="{'checking':'checking','approved':'approved','rejected':'rejected','revoked':'revoked','pending':'pending'}[leave.status]" ng-bind='leave.status'></a><!--<span class="glyphicon glyphicon-chevron-right"></span>-->
	                </span>
	            <!--</a>-->
               
            </li>
  
        </ul>
    </div>

</div>
		
		
		
	</body>
</html>